// https://www.lintcode.com/problem/valid-word-square/description
class Solution {
public:
    /**
     * @param words: a list of string
     * @return: a boolean
     */
    bool validWordSquare(vector<string> &words) {
        // if (words.size() == 0) return false;
        if (words.size() != words[0].size()) return false;
        int j = 0;
        for (int j = 0; j < words.size(); ++j)
        {
            for (int i = j; i < words[j].size(); ++i)
            {
                if (words[j][i] != words[i][j]) return false;
            }
        }
        return true;    
    }
};
